#ifndef __SQLITE_SQL_COMMAND_H_
#define __SQLITE_SQL_COMMAND_H_

#include <string>
#include <list>
#include <map>

#include "sqlite-sql-table-info.h"

class sql_command_base
{
public:
    struct field_item_value{
        std::string str_field;
        std::string str_value;
    };

    sql_command_base( std::string &str_name );
    virtual ~sql_command_base();

    //check if data can be created
    bool is_create() { return !m_key_value_list.empty(); }

    //data filling
    void set_field_item_value( const std::string str_field, const int i_value );
    void set_field_item_value( const std::string str_field, const unsigned int ui_value );
    void set_field_item_value( const std::string str_field, const signed long long val );
    void set_field_item_value( const std::string str_field, const char c_char);
    void set_field_item_value( const std::string str_field, const std::string &str_val);

protected:
    //data filling
    void set_field_item_value( const std::string str_field, const int val, std::list<field_item_value>& key_value);
    void set_field_item_value( const std::string str_field, const unsigned int val, std::list<field_item_value>& key_value);
    void set_field_item_value( const std::string str_field, const signed long long val, std::list<field_item_value>& key_value);
    void set_field_item_value( const std::string str_field, const char val, std::list<field_item_value>& key_value);
    void set_field_item_value( const std::string str_field, const std::string& val, std::list<field_item_value>& key_value);

protected:
    std::string             m_str_table_name;
    std::list<field_item_value>  m_key_value_list;
};


class sql_insert_command : public sql_command_base
{
public:
    sql_insert_command( std::string &str_name );
    ~sql_insert_command();

    std::string create_sql_statement();
};

class sql_update_command : public sql_command_base
{
public:
    sql_update_command( std::string &str_name );
    ~sql_update_command();

    void fill_item_where( const std::string &str_field, const int i_val );
    void fill_item_where( const std::string &str_field, const std::string &str_val );

    std::string create_sql_statement();

protected:
    std::list<field_item_value>  m_where_key_val;
};

class sql_delete_command : public sql_update_command
{
public:
    sql_delete_command( std::string &str_name );
    ~sql_delete_command();

    std::string create_sql_statement();
    std::string create_delete_all_sql_statement();
};

class sql_create_table_command
{
public:
    sql_create_table_command( const std::string &str_name );
    ~sql_create_table_command();

    void fill_item_field( const sql_column_info &col_info );
    std::string create_sql_statement();

private:
    std::string mstr_table_name;
    std::list<sql_column_info> m_field_list;
};

class sql_update_table_command
{
public:
    sql_update_table_command( const std::string &str_name );
    ~sql_update_table_command();

    void fill_item_field( const sql_column_info &col_info );
    std::string create_sql_statement();

private:
    std::string mstr_table_name;
    sql_column_info m_field;
};
#endif
